ScrollableRow is Container View which organizes his child Views horizontally like Row (next to each other).
But unlike Row you can scroll items horizontally if they don't all fit on the screen.
Syntax
import androidx.compose.foundation.ScrollableRow
import androidx.compose.foundation.layout.Row
ScrollableRow{
Row {
for (i in 0..100) {
Text(text = "$i Hello World!")
}
}
}
In this example we create ScrollableRow View with too many Text Views to fit horizontally on the screen.
MainActivity.kt
package com.example.testcompose
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.ScrollableRow
import androidx.compose.foundation.Text
import androidx.compose.foundation.layout.Row
import androidx.compose.ui.platform.setContent
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
ScrollableRow{
Row {
for (i in 0..100) {
Text(text = "$i Hello World!")
}
}
}
}
}
}
Output